package pojo;
import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/** 订单 */
@Entity
@Table(name="T_Order")
//@Table(name="`Order`")//因为表名是关键字，所以用分号
@Cache(include="all",usage = CacheConcurrencyStrategy.READ_WRITE)
public class Order implements Serializable {

	private static final long serialVersionUID = -5409386658105657900L;
	
	
	private Integer id; // id
	
	private String orderNumber; // 订单号
	
	private Customer customer; // 所属客户

	public Order() {
	}
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	@Column(length=255)
	public String getOrderNumber() {
		return orderNumber;
	}

	public void setOrderNumber(String orderNumber) {
		this.orderNumber = orderNumber;
	}
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="customer_id")//设置外键名
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@Override
	public String toString() {
		return "Order [id=" + id + ", orderNumber=" + orderNumber + "]";
	}

}
